/*
 * Copyright 2020-2025 the original author or authors.
 * You cannot use this file unless authorized by the author.
 */
package org.ipig.commons.service.dyna;

/**
 * DynaClassLoader
 *
 * @author <a href="mailto:comchnts@163.com">chinats</a>
 * @version $$Id: DynaClassLoader.java 3 2020-01-21 09:36:33Z ts <comchnts@163.com> $$
 * @since 1.0
 */
public class DynaClassLoader extends ClassLoader {
    public synchronized Class<?> loadClass(String name, byte[] data) {
        Class<?> cls = findLoadedClass(name);
        if (cls != null) {
            return cls;
        } else {
            try {
                return defineClass(null, data, 0, data.length);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return null;
    }
}